<?php include ("../smarty/libs/Smarty.class.php");

include ("../includes/common.php");
init(); 

//Forgot Password
if($_REQUEST[Type]=="ForgotPwd")
{
	pwdPage();
	die();
}

function pwdPage(){
	$smarty = new Smarty;
	$areas= get_row_con_info("areas","","","","0");
	$smarty->assign("areas",$areas);
	$smarty->display('forgotPwd.tpl');
}

//Login
if($_REQUEST[Type]=="Login")
{
	loginPage();
	die();
}

function loginPage(){
	$smarty = new Smarty;
	$areas= get_row_con_info("areas","","","","0");
	$smarty->assign("areas",$areas);
	$smarty->display('login.tpl');
}

if(isset($_POST['submit'])) {
 	session_start(); //starting the session for user profile page
 	if(!empty($_POST['email'])) //checking the 'email' from login.tpl, is it empty or have some text 
 	 { 
 	 $query = mysql_query("SELECT * FROM customers where email_Id = '$_POST[email]' AND password = '$_POST[password]'") or die(mysql_error()); 
 	 $row = mysql_fetch_array($query) or die(mysql_error()); 
 	 if(!empty($row['email_Id']) AND !empty($row['password'])) { 
 	 	$_SESSION['email_Id'] = $row['password']; 
 	 	$user=$row['first_name'];
		$smarty = new Smarty;
 	 	$smarty->assign('userName',$user);
 	 	$smarty->display('home.tpl'); 
 	 } 
 	 	else { 
 	 	echo "SORRY... YOU ENTERD WRONG ID AND PASSWORD... PLEASE RETRY..."; 
 	 	} 
 	 }
 	 else{
 	 	echo "Enter Your Email ID and Try Again";
 	 } 
 }
 
?>


